
let pin = document.querySelector(".pin");

let plBox_p = document.querySelector(".plBox_p")


window.onload = function () {
    //获取浏览器的query参数
    function getUrlParams() {
        let href = location.href;
        let regExp = /.+\?(.+)/;
        let param = regExp.exec(href)[1];
        console.log(param);
        // console.log(decodeURI(param));解码URI的参数编码

        let paramArr = param.split("&");
        console.log(paramArr);
        let query = {}
        paramArr.forEach(item => {
            itemArr = item.split("=");
            console.log(itemArr);
            query[itemArr[0]] = decodeURI(itemArr[1])
        })

        return query
    }

    let query = getUrlParams() //获取浏览器query参数
    console.log(query);

 
    ajax({
        url: "http://chst.vip:1234/api/getproduct",
        data: query,
    })
        .then(res => {
            let html = "";
            res = res.result;
            console.log(res);
            res.forEach(item => {
                html += `
                <div>
                   <p class="bbb">${item.productName}</p>
                   ${item.productImg}
                </div>
                <ul>
                    <li class="acti">比价购买</li>
                    <li>产品参数</li>
                    <li>评价(2322)</li>
                </ul>
            ${item.bjShop}
                `
            })
            pin.innerHTML = html;
        })
        .then(() => ajax({
            url: "http://chst.vip:1234/api/getproductcom",
            data: query,
        }))
        .then(res => {
            let str2 = "";
            res = res.result;
            console.log(res);
            res.forEach(item => {
                str2 += `
                <b>${item.comName}</b>
                <span>${item.comTime}</span><br>
                <span>${item.comFrom}</span><br>
                <p>${item.comContent}</p>
                `
            })
            plBox_p.innerHTML = str2;
        })
}
// let hh = document.querySelector(".hh");

// let plBox_p = document.querySelector(".plBox_p")
// $('.hh').click(function () {
//     $('.plBox_p').toggleClass('active')
//   })
//   hh.onclick = function(){
//       plBox_p.style.active = active
//   }
  
//   $(".hui").click(function () {
//     $("html,body").animate({ scrollTop: 0 }, 100);
// });





























